#include <stdio.h>
//1.sizeof返回的是实际所占用空间的大小,单位字节
//#pragma pack(1)
struct Person
{
        char a;
        int b;
};
void test01()
{
        printf("int size:%ld\n",sizeof(int)); //int size:4
        double a = 3.14;
        printf("a size:%ld\n", sizeof a); //a size:8
        printf("Person size:%ld\n", sizeof(struct Person)); //Person size:8
}

//2. sizeof返回结果类型是unsigned int
void test02()
{
        unsigned int a = 10;
        if( (a -20) > 0){ //大于0
                printf("大于0\n");
        }else{
                printf("小于0\n");
        }

        if(sizeof(int) -5 < 0){ //因为无符号始终是大于0的
                printf("< 0 \n");
        }else{
                printf("> 0 \n");       
        }
}
//3 sizeof计算数组
//数组作为函数参数会退化为指向数组首元素的指针
int caculateArraySize(int arr[])
{
        return sizeof(arr);
}
void test03()
{
        int arr[] = {1,2,3,4,5,6,7};
        printf("sizeof arr:%ld\n", sizeof(arr)); //sizeof arr:28
        printf("sizeof arr:%d\n", caculateArraySize(arr));//sizeof arr:8
}
int main(int argc, char const *argv[])
{
        test01();
        test02();
        test03();
        return 0;
}
